home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / SHOWFILE / MYMALLOC.S < prev    next >
Encoding:
Text File  |  2001-02-09  |  712 b   |  26 lines

  1. ;    char*
  2. ;    mymalloc(size)
  3. ;    int size;
  4. ;
  5. ;    returns whatever malloc() returns.
  6. ;
  7. .globl    _malloc
  8. _mymalloc::    move.w    sr, d0        ; Get status
  9.         btst    #$d, d0        ; In supervisor mode?
  10.         beq.s    USER        ; No, go to USER
  11.         
  12.         ; Yes, we are in supervisor mode.
  13.         ; move SSP to old USP
  14.         ; malloc, then move it back
  15.         move.w    4(sp), d0    ; Get arguement to malloc
  16.         move.l    a5, -(sp)    ; save a5
  17.         move.l    sp, a5        ; save current stack pointer
  18.         move.l    usp, sp        ; user's stack becomes current
  19.         move.w  d0, -(sp)    ; size to be allocated
  20.         jsr    _malloc        ; malloc it
  21.         move.l    a5, sp        ; restore saved stack pointer
  22.         move.l  (sp)+, a5    ; restore a5
  23.         rts            ; return in d0
  24.  
  25. USER:        jmp    _malloc        ; just malloc it
  26.